<template>
  <div>
    <z-table ref="table" rowKey="id" :showAlert="false" :showSelection="false" :loading="loading" :columns="columns"
      :dataSource="pageData" @change="onTableChange">
      <!--操作-->
      <template slot="action" slot-scope="text, record">
        <a-button @click="onInput(record)" type="link" style="padding: 0">添加评估</a-button>
        <a-divider type="vertical" />
        <a-button @click="onCX(record)" type="link" style="padding: 0">撤销申请</a-button>
        <a-divider type="vertical" />
        <a-button @click="onCYX(record)" type="link" style="padding: 0">催一下</a-button>
        <a-divider type="vertical" />
        <a-button @click="onDetail(record)" type="link" style="padding: 0">查看</a-button>
      </template>
    </z-table>
    
    <DetailModal ref="detailModalId"/>
  </div>
</template>
<script>
import { getUrge } from '@/api/sjsk/flowService'
import DetailModal from './DetailModal'
export default {
  components: {
    
    DetailModal,
  },

  data() {
    return {
      loading: false,
      columns: [
        {
          title: '序号',
          dataIndex: 'order',
          width: 60,
          align: 'center',
          customRender: (text, record, index) =>
            `${(this.pageFilter.pageNo - 1) * this.pageFilter.pageSize + (index + 1)}` //序号分页后连续
        },
        {
          title: '评估次数',
          dataIndex: 'taskName',
          align: 'center',
          customRender: (text) => {
            return <j-ellipsis value={text} length={14} />
          },
        },
        {
          title: '评估时段',
          dataIndex: 'incidentCode',
          align: 'center',
          customRender: (text) => {
            return <j-ellipsis value={text} length={20} />
          },
        },
        {
          title: '计划时间',
          dataIndex: 'incidentName',
          align: 'center',
          customRender: (text) => {
            return <j-ellipsis value={text} length={14} />
          },
        },
        {
          title: '录入状态',
          dataIndex: 'labelName',
          align: 'center',
          customRender: (text) => {
            return <j-ellipsis value={text} length={14} />
          },
        },
        {
          title: '评估时间',
          dataIndex: 'createTime1',
          align: 'center',
        },
        {
          title: '操作',
          width: 250,
          align: 'center',
          dataIndex: 'action',
          scopedSlots: { customRender: 'action' },
        },
      ],
      pageFilter: {
        pageNo: 1,
        pageSize: 10,
      },
      pageData: {
        records: [{
          taskCode: "11111"
        }]
      },
    }
  },
  created() { },
  async mounted() {
    // this.onQuery()
  },
  methods: {
    onQuery() {
      this.pageFilter.pageNo = 1
      // this.refreshTable()
    },
    // onTabChange(val) {
    //     this.pageFilter.pageNo = 1
    //     this.refreshTable()
    // },
    onTableChange(pagination, pageFilter, sorter) {
      let keyMap = { currentPage: 'pageNo' }
      let paginations = Object.keys(pagination).reduce((newData, key) => {
        let newKey = keyMap[key] || key
        newData[newKey] = pagination[key]
        return newData
      }, {})
      this.pageFilter = Object.assign({}, this.pageFilter, paginations)
      this.refreshTable()
    },
    refreshTable() {
      this.loading = true
      peopleApi
        .wxSeedPersonList(this.pageFilter)
        .then((res) => {
          if (res.success) {
            this.pageData = res.result ? res.result : {}
            this.loading = false
          } else {
            this.loading = false
          }
        })
        .catch((e) => {
          this.loading = false
          this.$message.warn('请求失败！')
        })
    },
    onInput() {
      this.$refs.addModalId.show()
    },
    onDetail() {
      this.$refs.detailModalId.show()
    },
    onCYX(record) {
      getUrge({ taskId: record.id, taskType: '19' }).then((res) => { //取消常规尿液检测审批
        if (res.success) {
          this.$message.success(res.message);
          this.onQuery()
        } else {
          this.$message.warning(res.message);
        }
      });
    },
    onCX() {
      let that = this;
      this.$confirm({
        title: `还在审批中，确定要撤销吗?`,
        okText: "确认",
        okType: "danger",
        cancelText: "取消",
        onOk() {
          // api.deleteTemplate({ id: arr }).then(() => {
          //   that.$message.success("删除成功");
          //   that.getTemplateList();
          // });
        }
      });
    },
  },
}
</script>
<style lang="less" scoped>

</style>
